﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Win.DAL;
using Win.Model;

namespace Win.BLL
{
    public class DishBLL
    {
        private DishDAL dishDAL = new DishDAL();

        public List<DishInfo> GetDishInfos()
        {
            return dishDAL.GetDishInfos();
        }

        public List<DishInfo> GetDishesByNT(string name , string type)
        {
            return dishDAL.GetDishesByNT(name, type);
        }

        public void AddDish(string name,string type,decimal price)
        {
            DishInfo dish = new DishInfo(name, price, type);
            DishInfo d = dishDAL.GetDishByName(name);
            if (d != null)
            {
                d.DTitle = name;
                d.DType = type;
                d.DPrice = price;
                dishDAL.UpdateDish(d);
            }
            else
            {
                dishDAL.AddDish(dish);
            }
        }

        public void DeleteDishById(int id)
        {
            dishDAL.DelDish(id);
        }
    }
}
